<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('学生信息列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input type="hidden" id="courseId" name="courseId" th:value="${courseChoose.courseId}">
                    <div class="select-list">
                        <ul>
                            <li>
                                年级：<select name="gradeId" th:with="type=${@dict.getType('sys_grade')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                            </li>
                            <li>
                                专业：<select name="professionalId" th:with="type=${@dict.getType('sys_professional')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                            </li>
                            <li>
                                班级：<select name="classId" th:with="type=${@dict.getType('sys_class')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:student:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:student:remove')}]];
        var gradeIdDatas = [[${@dict.getType('sys_grade')}]];
        var professionalIdDatas = [[${@dict.getType('sys_professional')}]];
        var classIdDatas = [[${@dict.getType('sys_class')}]];
        var prefix = ctx + "system/choose";

        $(function() {
            var options = {
                url: prefix + "/assignStudents/unallocatedList",
                modalName: "学生信息",
                queryParams: queryParams,
                sortName: "no",
                sortOrder: "asc",
                modalName: "学生",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                clickToSelect: true,
                rememberSelected: true,
                columns: [{
                    field: 'state',
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'no',
                    title: '学号'
                },
                {
                    field: 'name',
                    title: '姓名'
                },
                {
                    field: 'password',
                    title: '密码'
                },
                {
                    field: 'gradeId',
                    title: '年级',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(gradeIdDatas, value);
                    }
                },
                {
                    field: 'professionalId',
                    title: '专业',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(professionalIdDatas, value);
                    }
                },
                {
                    field: 'classId',
                    title: '班级',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(classIdDatas, value);
                    }
                },
                {
                    field: 'tel',
                    title: '电话'
                }]
            };
            $.table.init(options);
        });
        function queryParams(params) {
            var search = $.table.queryParams(params);
            search.courseId = $("#courseId").val();
            return search;
        }
        /* 添加用户-选择用户-提交 */
        function submitHandler() {
            var rows = $.table.selectFirstColumns();
            if (rows.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
            var data = { "courseId": $("#courseId").val(), "sIds": rows.join() };
            $.operate.save(prefix + "/assignStudents/unallocatedList/selectStudentsAll", data);
        }
    </script>
</body>
</html>
